/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


$(function() {
    parent.$(document).on('hidden.bs.modal', '.alert-modal', function(e) {
        $(this).remove();
    });
});




function get(controller, parametros, callback) {
    $.get(controller, parametros, function(data, status) {

        callback(data, false);

    }).fail(function(data, status) {

        callback(data.responseText, true);

    });
}
function post(controller, parametros, callback) {
    $.post(controller, parametros, function(data, status) {

        callback(data, false);

    }).fail(function(data, status) {

        callback(data.responseText, true);

    });
}


function showAlert() {

    var modal = '<div class="alert-modal modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">\n\
<div class="modal-dialog">\n\
<div class="modal-content">\n\
 <div class="modal-header">\n\
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>\n\
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>\n\
      </div>\n\
      <div class="modal-body">\n\
        ...\n\
      </div>\n\
      <div class="modal-footer">\n\
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>\n\
        <button type="button" onclick="showAlert();" class="btn btn-primary">Save changes</button>\n\
      </div>\n\
    </div>\n\
  </div>\n\
</div>';

    parent.$('body').append(modal);
    parent.$('.alert-modal').modal('show');

}

function hideAlert() {

}

function startLoadingButton(button) {
    $(button).button('loading');
}
function stopLoadingButton(button) {
    $(button).button('reset');
}

function resizeIframe(iframe) {
    var height = iframe.contentWindow.document.body.scrollHeight + 'px';
    $(iframe).animate({
        height: height
    }, 200);
//    iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}